fix: expose plugin root to claude -p via --add-dir#1
Merged
Conversation
The action spawned `claude -p` with `cwd` set to a per-case
`tempfile.mkdtemp(...)` working directory and no `--add-dir` flag, so
the subprocess could only read files inside that temp dir.
Skills that reference plugin-shipped reference files via the
documented `${CLAUDE_PLUGIN_ROOT}` plugin convention (e.g. shared
registries under `${CLAUDE_PLUGIN_ROOT}/data/*.yaml` or per-feature
config under `${CLAUDE_PLUGIN_ROOT}/spaces/*/*.md`) had every Read
and Grep denied because the resolved path was outside the allowed
working directory. The agent could never get past the first step
of any non-trivial skill that loads its own reference data.
Fix: resolve `PLUGIN_ROOT = SKILL_PATH.resolve().parent.parent`
(e.g. `plugins/<plugin>/skills/<skill>` -> `plugins/<plugin>`) at
module load and pass `--add-dir <PLUGIN_ROOT>` to the `claude -p`
subprocess.
`.resolve()` is required because `--add-dir` is interpreted relative
to the subprocess cwd (the per-case temp dir); a relative
`SKILL_PATH` (as set by the composite action input when callers pass
a workspace-relative path) would otherwise expand to a nonexistent
path inside that temp dir.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The action spawned
claude -pwithcwdset to a per-casetempfile.mkdtemp(...)working directory and no--add-dirflag, so the subprocess could only read files inside that temp dir.Skills that reference plugin-shipped reference files via the documented
${CLAUDE_PLUGIN_ROOT}plugin convention (e.g. shared registries under${CLAUDE_PLUGIN_ROOT}/data/*.yaml, per-feature config under${CLAUDE_PLUGIN_ROOT}/spaces/*/*.md, shared CSS / templates) had every Read and Grep denied because the resolved path was outside the allowed working directory. The agent could never get past the first step of any non-trivial skill that loads its own reference data.Change
scripts/eval.py:PLUGIN_ROOT = SKILL_PATH.resolve().parent.parentat module load (e.g.plugins/<plugin>/skills/<skill>->plugins/<plugin>).--add-dir <PLUGIN_ROOT>to theclaude -psubprocess in_run_claude..resolve()is required because--add-diris interpreted relative to the subprocess cwd (the per-case temp dir); a relativeSKILL_PATH(as set by the composite action input when callers pass a workspace-relative path) would otherwise expand to a nonexistent path inside that temp dir.Two-line change, no API or input surface change.
Why this is safe
--add-diris additive on top ofcwd. It only widens read access to the resolved plugin root; it does not change tool permissions or model behaviour. The per-case temp working directory continues to scope writes and the primary file surface for the eval case.